import { Ref } from "vue";
import * as XLSX from "xlsx";

interface T {
  [key: string]: string | number;
}

const exportXlsx = (tableData: T[], list: Array<Array<string>>) => {
  tableData.map((item: any, i: number) => {
    const arr: any[] = [i + 1];
    arr.push(...[item.name, item.sno, item.class, item.age, item.sex]);
    list.push(arr);
  });
  let WorkSheet = XLSX.utils.aoa_to_sheet(list);
  let new_workbook = XLSX.utils.book_new();
  XLSX.utils.book_append_sheet(new_workbook, WorkSheet, "第一页");
  XLSX.writeFile(new_workbook, `表格.xlsx`);
};

export default exportXlsx;
